<?php 
require_once('dao/OffreMobileDao.php');
if ($_SESSION['niveauAuth']=='1'or $_SESSION['niveauAuth']=='2' or $_SESSION['niveauAuth']=='5'or $_SESSION['niveauAuth']=='6'or $_SESSION['niveauAuth']=='7') {
/**
 * Controleur pour la creation d'offre achat mobile 
 */
	
	
//création d'une nouveaux terminal
if (isset($_POST['creation']))
{
$requete = $bdd->prepare("INSERT INTO `vente_terminal_mobile` (`id`, `code_article`, `libelle`, `tarif_nu`, `tarif_pack1g`, `tarif_compteur`, `tarif_offre_voix`,`tarif_pack2g`,`tarif_pack3g`) VALUES ('', '".$_POST['code_article']."', '".$_POST['libelle']."','".$_POST['tarif_nu']."','".$_POST['tarif_pack1g']."','".$_POST['tarif_compteur']."' ,'".$_POST['tarif_offre_voix']."','".$_POST['tarif_pack2g']."','".$_POST['tarif_pack3g']."') ");
			
			$requete->execute() or exit(print_r($bdd->errorInfo()));

	
	// Redirection vers la page 
	if ($_POST['action'] == "creation"){
			// Pas de changement de page
			$success=true;
	} else if ($_POST['action'] == "ve-terminal-mobile-creation"){
			header("Location:ve-offre-voip-creation.php?success=true");
	} else if ($_POST['action'] == "ve-terminal-mobile"){
		header("Location:ve-terminal-mobile?success=true");
	}
}

//$twig = new Twig_Environment($loader, array(
 //   'debug' => true,
//)); 
//$twig->addExtension(new Twig_Extension_Debug());
// a afficher dans le html: {{ debug() }}

echo $twig->render('ve-terminal-mobile-creation.html');

}
else {
	redirect("home-admin");
}